
/**
 * 功能描述  导航条
 */
define(function (require, exports, module) {
	var Subnav = require("subnav");
	var aw = require("ajaxwrapper");
	var enmu = require("enums");
	var user = require("store").get("user");

	
    var instance = {
        initComponent: function (params, widget) {
        	var subnav = new Subnav({
        		parentNode: ".J-subnav",
        		model:{
        			title:"会议准备",
        			items:[{
        				id:"search",
        				type:"search",
        				placeholder:"组团单位/目的地",
        				handler:function(str){
        					var grid=widget.get("grid");
        					aw.ajax({
        						url:"api/checkinmeeting/search*",
        						data:{
        							s:str,
        							searchProperties:"checkInImplement.groupReserve.planItemGroup.servicePoint.name," +
									"checkInImplement.groupReserve.planItemGroup.allianceOrg.name," +
									"checkInImplement.nonMemGroupReserve.nonMemberGroup.groupUnit",
        							fetchProperties:"*,checkInImplement.version," +
									"checkInImplement.pkCIImplement," +
									"checkInImplement.signUpNum," +
									"checkInImplement.dataSource.*," +
									"status.*," +
									"checkInImplement.groupReserve.*," +
									"checkInImplement.groupReserve.planItemGroup.allianceOrg.*," +
									"checkInImplement.groupReserve.planItemGroup.planItem.*," +
									"checkInImplement.groupReserve.planItemGroup.planItem.destination.*," +
									"checkInImplement.groupReserve.planItemGroup.servicePoint.pkServicePoint," +
									"checkInImplement.groupReserve.planItemGroup.servicePoint.name," +
									"checkInImplement.groupReserve.planItemGroup.signUps.version," +
									"checkInImplement.nonMemGroupReserve.nonMemberGroup.*," +
									"checkInImplement.nonMemGroupReserve.nonMemberGroup.groupUnit," +
									"checkInImplement.nonMemGroupReserve.nonMemberGroup.servicePoint.name," +
									"checkInImplement.nonMemGroupReserve.nonMemberGroup.signUpType.*," +
									"checkInImplement.nonMemGroupReserve.nonMemberGroup.operator.servicePoint.name," +
									"checkInImplement.nonMemGroupReserve.nonMemberGroup.signUps.version"
        						},
        						dataType:"json",
        						success:function(data){
        							grid.setData(data);
        						}
        					});
        				}
        			},{
        				id:"servicePoint",
        				type:"buttongroup",
//        				lazy: true,
        				tip:"服务点",
        				keyField :"pkServicePoint",
					    valueField : "name",
					    items:user.privateServicePoints,
//					    url : "api/servicepoint/operableservicepoints",
					    handler : function(key,element){
					    	widget.get("grid").refresh();
					    }
        			},{
        				id:"status",
        				tip: "状态",
        				type:"buttongroup",
        				items:[{
        					key: "Pending",
        					value: "待落实"
        				},{
        					key: "Pended",
        					value: "已落实"
        				}],
        				all : {
							show:true,
							position:"bottom"
						},
						tip:"状态",
						handler : function(key,element){
					    	widget.get("grid").refresh();
					    }
        			},{
        				id:"startDate",
        				tip: "入住日期",
        				type:"daterange",
        				ranges: {
        					 "本月": [moment().startOf("month"), moment().endOf("month")]
			            },
			            defaultRange: "本月",
        				handler : function(time){
							widget.get("grid").refresh();
						}
        			},{
						id:"return",
						type:"button",
						text:"返回",
						show : false,
						handler:function(){
							widget.show([".J-grid"]).hide([".J-form"]);
							widget.get("subnav").hide(["back"]).show(["search","checkStatus","servicePoint","dateRange"]);
							widget.get("grid").refresh();
						}
					}]
        		}
        	});
            widget.set("subnav",subnav);
        }
    };
    module.exports = instance;
});
